﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;

using FRL.DebtChased.Repository;

namespace FRL.DebtChased.Silverlight.Library
{

	/// <summary>
	/// Declaration of RequestModificationWnd class
	/// Form for requesting a modification to a field
	/// when the user does not have permission to directly edit the field
	/// </summary>
	public partial class RequestModificationWnd : ChildWindow
	{

		/////////////////////////////////////////////////////////////
		// Construction

		public RequestModificationWnd()
		{

			// This constructor is provided to help development
			// This constructor should never be called from code

			// Load xaml resources
			InitializeComponent();

		}

		public RequestModificationWnd( Definitions.eDataField dataField )
		{

			// Load xaml resources
			InitializeComponent();

			// Set controls
			tbFieldName.Text = ExtensionsForSilverlight.GetEnumDescription(
				typeof(Definitions.eDataField), 
				(int)dataField
			);

		}

		/////////////////////////////////////////////////////////////
		// Event handlers

		private void OKButton_Click(object sender, RoutedEventArgs e)
		{

			// Check content
			if (txtNewValue.Text.Length < 2)
			{
				MessageBoxes.PopupMessage("The new value must have at least two characters.");
				return;
			}

			// Confirm request
			if (!MessageBoxes.PopupOption("Send request for data modification?"))
				return;

			// TODO
			// What to do with this request?

			// Message for user
			MessageBoxes.PopupDevMessage();

		}

		private void CancelButton_Click(object sender, RoutedEventArgs e)
		{

			// Close window
			this.DialogResult = false;

		}

	}

}

